// EndPoint.cpp: implementation of the CEndPoint class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "PPEndPoint.h"
#include "RecordsetEx.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

PPEndPoint::PPEndPoint()
{

}

PPEndPoint::~PPEndPoint()
{

}
void PPEndPoint::GetEndPoint(_RecordsetPtr & pRs)
{
	CString strSQL=_T("");
	CRecordsetEx REx;
	REx.m_pCon=m_pCon;
	strSQL=_T("SELECT From_node as PSAnode, count(*) as PSAcount FROM \
		INPUT_BASIC_ELEMENT_DATA WHERE From_node not in ( select To_node from \
		INPUT_BASIC_ELEMENT_DATA ) and From_node not in (select  node1 from input_bends) \
		and From_node not in (select node2 from input_bends) and From_node not in \
		(select node3 from input_bends) group BY From_node  UNION select \
		To_node as PSAnode,count(*) as PSAcount from input_basic_element_data where \
		to_node not in (select from_node from Input_basic_element_data) and From_node \
		not in (select  node1 from input_bends) and From_node not in (select node2 from \
		input_bends) and From_node not in (select node3 from input_bends) group by to_node ");
	try
	{
		REx.OpenTable(pRs,strSQL);
		if(pRs->GetRecordCount()>0)
		{
			strSQL.Format(_T("PSAcount=1"));
			pRs->Filter=_bstr_t(strSQL);
		}
	}
	catch(_com_error e)
	{
		#ifdef _DEBUG
		AfxMessageBox(e.Description());
		#endif
	}
}
